﻿using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Unity;

namespace Arch.Common.IoC
{
    public static class UnityContainerExtentions
    {
        public static IUnityContainer InitDependencyContainer<T>(this IUnityContainer container) where T : IDependencyContainer
        {
            container.RegisterType<IDependencyContainer, T>(new ContainerControlledLifetimeManager());
            var locator = new ArchUnityServiceLocator(container);
            ServiceLocator.SetLocatorProvider(() => locator);
            ArchUnityDependencyContainer.InitContainer(container);
            return container;
        }
    }
}
